﻿
@{
    ViewBag.Title = "Index";
}
<style>
    a{
        color:black;
    }

    a:hover{
        color:red;
    }

    table {
        background-color: white;
        color: black;
        width: 90%;
        margin: auto;
        border-radius: 3px;
        text-align: center;
    }

    th {
        text-align: center;
        background-color: #585858;
    }

    .th-1 {
        border-top-left-radius: 3px;
    }

    .th-5 {
        border-top-right-radius: 3px;
    }
    .btn-submit {
        color: #fff;
        background-color: #000;
        border-color: #000;
    }

    .btn-return {
        color: #fff;
        background-color: #6a6a6a;
        border-color: #6a6a6a;
    }
    footer{
        position:fixed;
        left:0;
        bottom:0;
        width:100%;
    }
</style>

<table class="table table-responsive">
    <tr>
        <th class="th-1">序列</th>
        <th>公司名称</th>
        <th>公司地址</th>
        <th>联系电话</th>
        <th class="th-5">操作</th>
    </tr>
    @{  
        foreach (var item in ViewBag.InsererList)
        {
            int index = ViewBag.InsererList.IndexOf(item);
            <tr>
                <td>@(index + 1)</td>
                <td>@item.insurerName</td>
                <td>@item.readdress</td>
                <td>@item.phone</td>
                <td>
                    <a href="/Inserer/ModInsererView/@item.insurer_id">编辑</a>
                    <a href="#@item.insurer_id" data-toggle="modal">删除</a>
                    <div class="modal" id="@item.insurer_id">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <div class="modal-title">
                                        删除提示
                                    </div>
                                </div>
                                <div class="modal-body">
                                    你确认要删除公司【@item.insurerName】？
                                </div>
                                <div class="modal-footer">
                                    <button class="btn btn-submit" onclick="delInserer(@item.insurer_id)">确定</button>
                                    <button class='btn btn-return' data-dismiss="modal">取消</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
        }
    }
</table>
<link href="~/Content/page.css" rel="stylesheet" />
@Html.Partial("Page");
<script type="text/javascript">
    function delInserer(id) {
        $.post("/Inserer/DelInserer", { id: id }, function (o) {
            if(o == "成功"){
                location.href = "/Inserer/Index";
            } else{
                $('.modal').modal('hide');
                $('.modal-backdrop').hide();
                alert("删除失败," + o);
            }
        });
    }
</script>
